package org.cl.persist.note.controller;

import org.cl.persist.note.service.impl.NoteServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author 86130
 */
@Controller
public class PageController {

    @Autowired
    private NoteServiceImpl noteService;

    @GetMapping("/biji")
    public ModelAndView getNoteView(String name) {
        if (name == null || name.length() < 1) {
            name = "algorithm";
        }
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("content", noteService.getNoteContent(name));
        modelAndView.addObject("filenames", noteService.getNoteDir());
        modelAndView.setViewName("note");
        return modelAndView;
    }

    @GetMapping("/tools")
    public ModelAndView getToolsView() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("tools");
        return modelAndView;
    }

    @GetMapping("/collect")
    public ModelAndView getCollectView() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("collect");
        return modelAndView;
    }
}
